package org.alwayssuper.protocol.gbt32960;

import org.alwayssuper.protostar.annotation.Field;
import org.alwayssuper.protostar.annotation.Message;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.alwayssuper.protocol.basics.GBTMessage;
import org.alwayssuper.protocol.commons.GBTRequestType;

import java.time.LocalDateTime;

/**
 * G05 平台登入
 * 支持GB/T 32960.3-2016 (version=0) 和 GB/T 32960.3-2025 (version=1) 两个版本
 * 
 * 用于平台间登入认证
 * 
 * @author alwaysSuper
 */
@ToString
@Data
@Accessors(chain = true)
@Message(GBTRequestType.平台登入)
public class G05 extends GBTMessage {
    @Field(length = 6, desc = "平台登入时间(YYMMDDHHMMSS)")
    private LocalDateTime loginTime;
    
    @Field(length = 2, desc = "登入流水号:平台每登入一次,登入流水号自动加1,从1开始循环累加,最大值为65531")
    private int loginSeqNo;
    
    @Field(length = 12, charset = "ASCII", desc = "平台用户名:平台登入用户名,不足12字节时用0填充")
    private String platformUsername;
    
    @Field(length = 20, charset = "ASCII", desc = "平台密码:平台登入密码,不足20字节时用0填充")
    private String platformPassword;
    
    @Field(length = 1, desc = "加密规则:0x01:不加密;0x02:RSA算法加密;0x03:AES128算法加密;0x04:SM2算法加密;0x05:SM4算法加密")
    private int encryptionRule;
    
    @Override
    public int getSerialNo() {
        return loginSeqNo;
    }
}